package com.ruoyi.erp.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.erp.domain.LedyBacFeeConfig;
import com.ruoyi.erp.service.ILedyBacFeeConfigService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 凭证生成规则Controller
 * 
 * @author ztj
 * @date 2023-05-09
 */
@RestController
@RequestMapping("/erp/feeconfig")
public class LedyBacFeeConfigController extends BaseController
{
    @Autowired
    private ILedyBacFeeConfigService ledyBacFeeConfigService;

    /**
     * 查询凭证生成规则列表
     */
    @PreAuthorize("@ss.hasPermi('erp:feeconfig:list')")
    @GetMapping("/list")
    public TableDataInfo list(LedyBacFeeConfig ledyBacFeeConfig)
    {
        startPage();
        List<LedyBacFeeConfig> list = ledyBacFeeConfigService.selectLedyBacFeeConfigList(ledyBacFeeConfig);
        return getDataTable(list);
    }

    /**
     * 导出凭证生成规则列表
     */
    @PreAuthorize("@ss.hasPermi('erp:feeconfig:export')")
    @Log(title = "凭证生成规则", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, LedyBacFeeConfig ledyBacFeeConfig)
    {
        List<LedyBacFeeConfig> list = ledyBacFeeConfigService.selectLedyBacFeeConfigList(ledyBacFeeConfig);
        ExcelUtil<LedyBacFeeConfig> util = new ExcelUtil<LedyBacFeeConfig>(LedyBacFeeConfig.class);
        util.exportExcel(response, list, "凭证生成规则数据");
    }

    /**
     * 获取凭证生成规则详细信息
     */
    @PreAuthorize("@ss.hasPermi('erp:feeconfig:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(ledyBacFeeConfigService.selectLedyBacFeeConfigById(id));
    }

    /**
     * 新增凭证生成规则
     */
    @PreAuthorize("@ss.hasPermi('erp:feeconfig:add')")
    @Log(title = "凭证生成规则", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody LedyBacFeeConfig ledyBacFeeConfig)
    {
        return toAjax(ledyBacFeeConfigService.insertLedyBacFeeConfig(ledyBacFeeConfig));
    }

    /**
     * 修改凭证生成规则
     */
    @PreAuthorize("@ss.hasPermi('erp:feeconfig:edit')")
    @Log(title = "凭证生成规则", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody LedyBacFeeConfig ledyBacFeeConfig)
    {
        return toAjax(ledyBacFeeConfigService.updateLedyBacFeeConfig(ledyBacFeeConfig));
    }

    /**
     * 删除凭证生成规则
     */
    @PreAuthorize("@ss.hasPermi('erp:feeconfig:remove')")
    @Log(title = "凭证生成规则", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(ledyBacFeeConfigService.deleteLedyBacFeeConfigByIds(ids));
    }
}
